package ly.count.android.demo.kotlin

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import ly.count.android.demo.kotlin.databinding.FragmentMainListBinding

/**
 * Fragment for the main list
 */
class FragmentMainList : Fragment() {
  private var _binding: FragmentMainListBinding? = null

  private val binding get() = _binding!!
  private lateinit var recyclerView: RecyclerView

  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
  }

  override fun onCreateView(
    inflater: LayoutInflater,
    container: ViewGroup?,
    savedInstanceState: Bundle?
  ): View? {
    _binding = FragmentMainListBinding.inflate(inflater, container, false)
    val view = binding.root
    return view
  }

  override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
    recyclerView = binding.recyclerView
    recyclerView.layoutManager = LinearLayoutManager(context)
    recyclerView.adapter = AdapterMainList()
  }

  override fun onDestroyView() {
    super.onDestroyView()
    _binding = null
  }

}
